package com.example.juc.big_talk_concurrent.chapter6.article1;

import java.util.concurrent.CountDownLatch;

public class Test1 {
    static CountDownLatch countDownLatch = new CountDownLatch(2);

    public static void main(String[] args) throws InterruptedException {

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("first thing finish");
                countDownLatch.countDown(); // count --
                System.out.println("second thing finish");
                countDownLatch.countDown(); // count --
            }
        }).start();

        countDownLatch.await(); // 主线程被阻塞住，直到 count = 0
        System.out.println("FINISH");

    }
}
